﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>边打字边显示字数</title>
    <script language="JavaScript">
        function Check(txt)
        {
            TextCount=txt.value.length;  //获取文本框的长度
            div1.innerText=TextCount;    //将长度显示在div中
        }
    </script>
</head>
<body>
<textarea type=text id=txt1 onkeyup="Check(this) " onKeyDown="Check(this)">
</textarea><br />当前字符数：<div id="div1"></div>
</body>
</html>